import { storeBindingsBehavior } from 'mobx-miniprogram-bindings'
import { store } from '../store/store'
Component({
// 覆盖自定义样式tabbar样式
     options: {
        styleIsolation: 'shared'
      },
      behaviors: [storeBindingsBehavior],
      storeBindings: {
        store,
        //active 是相当于data中的值,activeTabBarIndex是store中的值,页面使用active
        fields: {active: 'activeTabBarIndex'},
        actions: {updateActive: 'updateActiveTabBarIndex'},
      },
    /**
     * 组件的属性列表
     */
    properties: {
    },
    /**
     * 组件的初始数据
     */
    data: {
        active: 0,
        "list": [{
            "pagePath": "/pages/index/index",
            "text": "首页",
            "iconPath": "/images/tabs/home.png",
            "selectedIconPath": "/images/tabs/home-active.png",
            "info":2
        },{
          "pagePath": "/pages/message/message",
          "text": "消息",
          "iconPath": "/images/tabs/message.png",
          "selectedIconPath": "/images/tabs/message-active.png"
      },{
          "pagePath": "/pages/contact/contact",
          "text": "联系方式",
          "iconPath": "/images/tabs/contact.png",
          "selectedIconPath": "/images/tabs/contact-active.png"
      }]
    },

    /**
     * 组件的方法列表
     */
    methods: {
        onChange(event) {
            // event.detail 的值为当前选中项的索引
            this.updateActive(event.detail)
            console.log(event.detail)
            wx.switchTab({
              url: this.data.list[event.detail].pagePath,
            })
          },
    }
})